import React, { Component } from 'react'
import {
    StyleSheet,
    View,
    Text,
    TouchableOpacity,
    Image,
    NativeModules,
    DeviceEventEmitter
} from 'react-native';

import BaseBridge from '../../common/Native/BaseBridge';

class A extends Component {

    componentWillMount() {

        DeviceEventEmitter.addListener('TokenFreshed_NativeEmitter', function (token) {
            alert("send success" + token);
        });

    }



    render() {
        return (
            <View style={{ flex: 1 }}>
                <TouchableOpacity
                    onPress={() => {
                        this.props.navigation.navigate("B", {
                            id: new Date().getTime()
                        });
                    }}
                    style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}
                >
                    <Text style={{ fontSize: 30, color: 'red' }}>跳到B</Text>

                </TouchableOpacity>
                <TouchableOpacity
                    onPress={() => {
                        this.props.navigation.navigate("C", {
                            id: new Date().getTime()
                        });
                    }}
                    style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}
                >
                    <Text style={{ fontSize: 30, color: 'red' }}>跳到C</Text>

                </TouchableOpacity>
                <TouchableOpacity
                    onPress={() => {
                        NativeModules.BaseBridge.playVideo('http://test.video.juziwl.cn/elearning/20180820/bac84be788f846fb9535d5b2f2417f36.mp4');
                    }}
                    style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}
                >
                    <Text style={{ fontSize: 30, color: 'red' }}>playVideo</Text>

                </TouchableOpacity>


                <TouchableOpacity
                    onPress={() => {
                        NativeModules.BaseBridge.login().then((res) => {
                            global.log(res);
                            // alert(res);
                        });
                    }}
                    style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}
                >
                    <Text style={{ fontSize: 30, color: 'red' }}>登陆</Text>

                </TouchableOpacity>

                <TouchableOpacity
                    onPress={() => {
                        NativeModules.BaseBridge.setPayPassword();
                    }}
                    style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}
                >
                    <Text style={{ fontSize: 30, color: 'red' }}>测试通知</Text>

                </TouchableOpacity>

                <TouchableOpacity
                    onPress={() => {
                        NativeModules.BaseBridge.saveBridge();
                    }}
                    style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}
                >
                    <Text style={{ fontSize: 30, color: 'red' }}>保存bridge</Text>

                </TouchableOpacity>

            </View>
        )
    }


}


const styles = StyleSheet.create({
    navigatorBar: {
        backgroundColor: '#BFBFBF'
    }

});

export default A;